<template>
  <div class="frame">
    <div class="banner">
      <!-- 轮播图 -->
      <div class="swiper" ref="swiper" style="overflow: hidden">
        <div class="swiper-wrapper">
          <div class="swiper-slide">
            <a href="">
              <img src="./images/banner1.jpg" alt="" />
            </a>
            <span class="title">
              <a href="">
                周深、王者荣耀 - 很高兴遇见你 (王者荣耀七周年遇见主题曲)
              </a>
              <em></em>
            </span>
            <span class="bg"></span>
          </div>
          <div class="swiper-slide">
            <a href="">
              <img src="./images/banner2.jpg" alt="" />
            </a>
            <span class="title">
              <a href="">
                周深、王者荣耀 - 很高兴遇见你 (王者荣耀七周年遇见主题曲)
              </a>
              <em></em>
            </span>
            <span class="bg"></span>
          </div>
          <div class="swiper-slide">
            <a href="">
              <img src="./images/banner3.jpg" alt="" />
            </a>
            <span class="title">
              <a href="">
                周深、王者荣耀 - 很高兴遇见你 (王者荣耀七周年遇见主题曲)
              </a>
              <em></em>
            </span>
            <span class="bg"></span>
          </div>
          <div class="swiper-slide">
            <a href="">
              <img src="./images/banner4.jpg" alt="" />
            </a>
            <span class="title">
              <a href="">
                周深、王者荣耀 - 很高兴遇见你 (王者荣耀七周年遇见主题曲)
              </a>
              <em></em>
            </span>
            <span class="bg"></span>
          </div>
          <div class="swiper-slide">
            <a href="">
              <img src="./images/banner5.jpg" alt="" />
            </a>
            <span class="title">
              <a href="">
                周深、王者荣耀 - 很高兴遇见你 (王者荣耀七周年遇见主题曲)
              </a>
              <em></em>
            </span>
            <span class="bg"></span>
          </div>
          <div class="swiper-slide">
            <a href="">
              <img src="./images/banner6.jpg" alt="" />
            </a>
            <span class="title">
              <a href="">
                周深、王者荣耀 - 很高兴遇见你 (王者荣耀七周年遇见主题曲)
              </a>
              <em></em>
            </span>
            <span class="bg"></span>
          </div>
        </div>
        <div class="swiper-pagination" slot="pagination"></div>
      </div>
      <!-- mv热播列表 -->
      <div class="mvHotList">
        <h3>
          <span>MV热播总排行</span>
          <a
            target="_blank"
            href="https://www.kugou.com/mvweb/html/mvlist.html"
          >
            更多
          </a>
        </h3>
        <ul>
          <li>
            <a
              target="_blank"
              href="https://www.kugou.com/mvweb/html/mvlist.html"
            >
              <span class="one num"></span>
              <span class="name">Nxde</span>
              <em class="mask"></em>
            </a>
          </li>
          <li>
            <a
              target="_blank"
              href="https://www.kugou.com/mvweb/html/mvlist.html"
            >
              <span class="two num"></span>
              <span class="name">故事还长</span>
              <em class="mask"></em>
            </a>
          </li>
          <li>
            <a
              target="_blank"
              href="https://www.kugou.com/mvweb/html/mvlist.html"
            >
              <span class="three num"></span>
              <span class="name">焰火</span>
              <em class="mask"></em>
            </a>
          </li>
          <li>
            <a
              target="_blank"
              href="https://www.kugou.com/mvweb/html/mvlist.html"
            >
              <span class="four num"></span>
              <span class="name">红颜如霜</span>
              <em class="mask"></em>
            </a>
          </li>
          <li>
            <a
              target="_blank"
              href="https://www.kugou.com/mvweb/html/mvlist.html"
            >
              <span class="five num"></span>
              <span class="name">耍把戏</span>
              <em class="mask"></em>
            </a>
          </li>
          <li>
            <a
              target="_blank"
              href="https://www.kugou.com/mvweb/html/mvlist.html"
            >
              <span class="six num"></span>
              <span class="name">星野《晚风告白》晚风很特别 擅于留白细节</span>
              <em class="mask"></em>
            </a>
          </li>
          <li>
            <a
              target="_blank"
              href="https://www.kugou.com/mvweb/html/mvlist.html"
            >
              <span class="seven num"></span>
              <span class="name"
                >广东吴勇《破碎的梦》凌晨的天空有冷的风吹痛我面容！</span
              >
              <em class="mask"></em>
            </a>
          </li>
          <li>
            <a
              target="_blank"
              href="https://www.kugou.com/mvweb/html/mvlist.html"
            >
              <span class="eight num"></span>
              <span class="name"
                >李认针《谁的生活不是鸡零狗碎》谁的生活又是顺风顺水！</span
              >
              <em class="mask"></em>
            </a>
          </li>
          <li>
            <a
              target="_blank"
              href="https://www.kugou.com/mvweb/html/mvlist.html"
            >
              <span class="nine num"></span>
              <span class="name"
                >彤大王《下辈子还要和你成个家》等到满嘴没牙说不清楚话！</span
              >
              <em class="mask"></em>
            </a>
          </li>
          <li>
            <a
              target="_blank"
              href="https://www.kugou.com/mvweb/html/mvlist.html"
            >
              <span class="ten num"></span>
              <span class="name"
                >云汐《故事还长》不惧黑夜太过漫长，我知道你在身旁！</span
              >
              <em class="mask"></em>
            </a>
          </li>
        </ul>
      </div>
    </div>

    <div class="radioWarp">
      <div class="leftCon">
        <h3 class="radio-left-title">MV分类</h3>
        <div class="radioList">
          <ul>
            <li
              v-for="(item, index) in sortList"
              :key="item.id"
              :class="currentIndex === index ? 'active-class' : 'common-class'"
              @click="switchType(item.area, index)"
            >
              {{ item.title }}
            </li>
          </ul>
        </div>
      </div>
      <div class="rightCon">
        <h3 class="radio-right-title">{{ categoryTitle }}</h3>
        <div class="mvList">
          <ul v-if="isShowList">
            <li v-for="(item, index) in newSongsList" :key="item.id">
              <router-link to="musicVideo/videoPlayer">
                <img v-lazy="newSongsList[index].cover" alt="" />
                <em></em>
                <i></i>
                <span
                  >{{ newSongsList[index].artistName }}-{{
                    newSongsList[index].name
                  }}</span
                >
              </router-link>
            </li>
          </ul>
          <ul else>
            <li v-for="(item, index) in choicenessList" :key="item.id">
              <router-link to="/musicVideo/videoPlayer">
                <img v-lazy="choicenessList[index].cover" alt="" />
                <em></em>
                <i></i>
                <span
                  >{{ choicenessList[index].artistName }}-{{
                    choicenessList[index].name
                  }}</span
                >
              </router-link>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Swiper from "swiper";
import "swiper/css/swiper.min.css";
import { reqNewMv } from "@/api/index";
import { reqAllMv } from "@/api/index";

export default {
  name: "MusicVideo",
  data() {
    return {
      newSongsList: [],
      currentIndex: 0,
      choicenessList: [],
      sortList: [
        {
          id: 1,
          area: "",
          title: "新歌推荐",
        },
        {
          id: 2,
          area: "内地",
          title: "华语精选",
        },
        {
          id: 3,
          area: "港台",
          title: "港台精选",
        },
        {
          id: 4,
          area: "欧美",
          title: "欧美精选",
        },
      ],
      isShowList: true,
      categoryTitle: "",
    };
  },
  mounted() {
    new Swiper(this.$refs.swiper, {
      // 左右轮播图间隔的距离
      spaceBetween: 10,
      // effect: "fade",
      // 第一张轮播图往第二张轮播图切换总共的时间
      speed: 2000,
      // 无限轮播 从第一张开始
      loop: true,
      autoplay: {
        // 一张轮播图延迟一秒
        delay: 1000,
        // 点击之后禁用轮播 默认为false
        disableOnInteraction: false,
      },
      pagination: {
        el: ".swiper-pagination",
        clickable: true,
      },
      // navigation 导航 左右按钮切换
      navigation: {
        nextEl: ".swiper-button-next",
        prevEl: ".swiper-button-prev",
      },
    });
    this.getNewMvList();
    this.categoryTitle = this.sortList[0].title;
  },
  methods: {
    async getNewMvList() {
      const result = await reqNewMv();
      this.newSongsList = result.data;
    },
    async getChoicenessList(type) {
      const result = await reqAllMv(type);
      this.choicenessList = result.data;
    },
    switchType(val, index) {
      if (val) {
        this.area = val;
        this.isShowList = false;
        this.currentIndex = index;
        this.getChoicenessList(val);
        this.categoryTitle = this.sortList[index].title;
      } else {
        this.isShowList = true;
        this.currentIndex = index;
        this.getNewMvList();
        this.categoryTitle = this.sortList[index].title;
      }
      // console.log(111);
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.frame {
  width: 1000px;
  margin: 0 auto;

  /* border: 1px solid red; */
}
.frame .banner {
  display: flex;
}
.swiper {
  margin-top: 20px;
  width: 663px;
  height: 325px;
  position: relative;
}

.swiper .swiper-pagination {
  position: absolute;
  left: 550px;
  bottom: 10px;
  /* border: 1px solid red; */
  width: 100px;
  height: 10px;
}

.swiper-slide .bg {
  position: absolute;
  /* z-index: 90; */
  top: 285px;
  width: 663px;
  height: 40px;
  line-height: 40px;
  display: block;
  color: #fff;
  background: #000;
  opacity: 0.5;
}
.swiper-slide .title a {
  z-index: 99;
  position: relative;
  font-weight: bold;
  font-size: 13px;
  padding: 3px 20px 3px 20px;
  color: #fff;
}
.swiper-slide .title em {
  display: inline-block;
  width: 18px;
  height: 18px;
  position: absolute;
  left: 5px;
  top: 4px;
  background: url(./images/play.png);
}
.mvHotList {
  width: 317px;
  height: 325px;
  margin-top: 20px;
  margin-left: 20px;
}
.mvHotList h3 {
  height: 30px;
  line-height: 30px;
  font-size: 14px;
  display: flex;
  font-weight: normal;
}
.mvHotList h3 span {
  padding-left: 5px;
  width: 219px;
  padding-left: 15px;
  background: #deb200;
  margin-right: 1px;
  color: #fff;
}
.mvHotList h3 a {
  display: block;
  width: 82px;
  background: #363636;
  text-align: center;
  color: #fff;
  text-decoration: none;
}
.mvHotList ul {
  background: #363636;
  margin-top: 2px;
  height: 293px;
}
.mvHotList ul li {
  height: 29px;
  line-height: 29px;
  position: relative;
}
.mvHotList ul li a {
  height: 32px;
  line-height: 32px;
  display: block;
  color: #fff;
  text-decoration: none;
  padding-left: 3px;
  cursor: pointer;
}
.mvHotList ul li a .num {
  display: inline-block;
  height: 32px;
  line-height: 32px;
  width: 37px;
  background: url(./images/bg.png) no-repeat;
}
.mvHotList ul li a span.one {
  background-position: -336px -218px;
}
.mvHotList ul li a span.two {
  background-position: -336px -247px;
}
.mvHotList ul li a span.three {
  background-position: -336px -276px;
}
.mvHotList ul li a span.four {
  background-position: -336px -305px;
}
.mvHotList ul li a span.five {
  background-position: -336px -334px;
}
.mvHotList ul li a span.six {
  background-position: -336px -363px;
}
.mvHotList ul li a span.seven {
  background-position: -336px -392px;
}
.mvHotList ul li a span.eight {
  background-position: -336px -421px;
}
.mvHotList ul li a span.nine {
  background-position: -336px -450px;
}
.mvHotList ul li a span.ten {
  background-position: -336px -479px;
}
.mvHotList ul li a .name {
  height: 32px;
  line-height: 32px;
  display: inline-block;
  width: 220px;
  background-color: #363636;
  overflow: hidden;
}
.mask {
  position: absolute;
  width: 100%;
  height: 100%;
  bottom: 0;
  left: 0;
  color: #ffffff;
  opacity: 0;
  background: rgba(101, 101, 101, 0.6);
}
.mvHotList ul li a:hover .mask {
  opacity: 1;

  /* cursor: default; */
}
.radioWarp {
  margin-top: 18px;
  /* border: 1px solid green; */
}
.radioWarp:after {
  content: "";
  display: block;
  visibility: hidden;
  clear: both;
}
.leftCon {
  float: left;
  width: 210px;
  /* border: 1px solid red; */
}
.rightCon {
  width: 780px;
  float: right;
  /* border: 1px solid gold; */
}
.leftCon .radio-left-title {
  height: 30px;
  text-align: center;
  line-height: 30px;
  background-color: #cfcfcf;
  font-size: 16px;
  color: #fff;
  font-weight: normal;
}
.radioList {
  padding-top: 10px;
  /* background-color: darksalmon; */
}
.radioList ul li {
  text-align: center;
  font-size: 14px;
  height: 36px;
  line-height: 36px;
  font-family: Microsoft YaHei;
}
.radioList ul .common-class a {
  display: block;
  height: 36px;
  color: #555;
  text-align: center;
  font-size: 14px;
}
.radioList ul .active-class {
  background-color: #85d4f3;
  color: #fff;
}
.radioList ul li:hover {
  background-color: #85d4f3;
  color: #fff;
}
.rightCon .radio-right-title {
  height: 30px;
  text-align: center;
  line-height: 30px;
  background-color: #cfcfcf;
  font-size: 16px;
  color: #fff;
  font-weight: normal;
}
.rightCon .mvList ul {
  padding-top: 10px;
  display: flex;
  /* justify-content: space-between; */
  flex-wrap: wrap;
}
.rightCon .mvList ul li {
  width: 20%;
  height: 110px;
  position: relative;
}
.rightCon .mvList ul li a {
  width: 140px;
  height: 78px;
  border-radius: 6px;
  display: block;
}
.rightCon .mvList ul li img {
  width: 140px;
  height: 78px;
  border-radius: 6px;
}
.rightCon .mvList ul li em {
  position: absolute;
  z-index: 99;
  right: 22px;
  top: 45px;
  background: url(./images/play.png) no-repeat;
  width: 22px;
  height: 22px;
}
.rightCon .mvList ul li span {
  width: 124px;
  text-overflow: ellipsis;
  display: block;
  overflow: hidden;
  margin: 5px 0 0 3px;
  color: #555;
  white-space: nowrap;
  font-family: "微软雅黑", Arial, Helvetica, sans-serif;
  font-size: 14px;
}
</style>
